package com.atguigu.IO;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 1.IP分类:IPV4和IPV6   万维网和局域网
 * 2.域名：www.baidu.com 类似
 * 3.本地回路地址:127.0.0.1   对应着localhost
 * 4.如何实例化InetAddress:两个方法  getByName(String host)和getLocalHost()
 *  两个常用方法:getHostName() /  getHostAddress
 */
public class InetAddressTest {
    public static void main(String[] args) throws UnknownHostException {
        InetAddress address = InetAddress.getByName("192.168.10.14");
        System.out.println(address);

        InetAddress address1 = InetAddress.getByName("www.baidu.com");
        System.out.println(address1);

        InetAddress address2=InetAddress.getByName("127.0.0.1"); //本机地址
        System.out.println(address2);

        //
        System.out.println(InetAddress.getLocalHost().getHostName());
        System.out.println(InetAddress.getLocalHost()); //直接获取本机的IP地址
    }
}
